/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			ETVpCmd_NewSubI.h
  \date			Sep 2011
  \author		TNick

  \brief		Contains the definition for ETVpCmd_NewSubI class


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
 * Neither the name of the copyright holder nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __ETVPCMD_NEWSUBI_INC__
#define __ETVPCMD_NEWSUBI_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<sheet/ETVpCommand.h>
#include	<sheet/ETSubItem.h>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// command used to create new sub-items; may create all known types
/**
*	This command has two ways to accomplish this task:
*	- if there is a current sub-item in the viewport then, when start() is
*	called, will insert requested type of item and stop
*	- otherwise it will allow the user to select a point and
*		- create a new ETI_CplxTxt and, inside it, a new sub-item of specified
*		type
*		- insert the new sub-item in the ETI_CplxTxt instance that lies at that
*		point (in a place decided by the point indicated by the hit)
*
*/
class ETVpCmd_NewSubI : public ETVpCommand		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// the type of the item to create
	ETSubItem::SIType		ty;



	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor;
	ETVpCmd_NewSubI		(
			ETSubItem::SIType new_ty = ETSubItem::TYSTEXT	/**< by default
		create a simple text item */
			);

	/// destructor;
	virtual				~ETVpCmd_NewSubI		( void );


	/// the class is informed that the command is starting
	/**
  *	Commands are started by creating an instance of a class inherited from
  *	ETVpCommand and passing it to startCommand(). While current implementation
  *	will always call ETVpCommand::start(), this may change in the future. As a
  *	result the command (class) shall only initialise itself when it recieves
  *	the ETVpCommand::start(), not in constructor.
  *
  *	@return		true to continue loading or false to cancel
  */
	bool				start		(
			ETSheetView *		trg_vp		/**< target viewport */
			);


	/// the class is informed that the command is being canceled
	/**
  *	The call to this function may or may not be preceded by a call to
  *	accepted(), depending on the user actions. It is usually called
  *	just before destroying the instance. However, the implementations
  *	shall free allocated resources here and not in destructor.
  */
	void				cancel		(
			ETSheetView *		trg_vp		/**< target viewport */
			);

protected:

	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Events forwarded by the viewport    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

	bool		mousePress	(
			ETSheetView *	vp,
			QMouseEvent * event);


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Options (to be set before start() ) */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

public:


	/// set / change the object that will be generated
	inline void					setType			(ETSubItem::SIType new_ty)
	{ ty = new_ty; }


	/// tell what kind of object will be generated
	inline ETSubItem::SIType	type			(void)
	{ return ty; }



	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class ETVpCmd_NewSubI	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __ETVPCMD_NEWSUBI_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
